#include <glib.h>

typedef struct my_data {
    gint id;
    gchar *name;
    gchar *memo;
}my_data_t;

void my_data_destroy_func(gpointer data)
{
    my_data_t *d = (my_data_t *)data;
    g_return_if_fail(d);

    if(NULL != d->name) {
        g_free(d->name);
    }

    if(NULL != d->memo) {
        g_free(d->memo);
    }

    g_free(d);
}

gint main(gint argc, gchar **argv)
{
    my_data_t *d = NULL;

    d = g_new0(my_data_t, 1);
    g_return_val_if_fail(d, -1);

    d->id = 100;
    d->name = g_strdup("abcd");
    d->memo = g_strdup("the memo info");

    g_print("d->id:%d, d->name:%s, d->memo:%s \n", d->id, d->name, d->memo);
    
    //g_free(d->name);
    //g_free(d->memo);
    //g_free(d);
    g_clear_pointer(&d, my_data_destroy_func);

    return 0;
}